package com.ktjiaoyu.crm.config;

import com.ktjiaoyu.crm.web.interceptor.AuthorizationInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 *拦截器配置
 * @author Administrator
 */
//@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    private String[] excludePathPatterns;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截器路径规则
        String[] pathPatterns = {"/**"};
        //排除路径规则
        String[] excludePathPatterns = {"/", "/login", "/dologin", "/css/**", "/js/**",
                "/fonts/**", "/images/**", "/localcss/**", "/localjs/**"};
        //注册拦截器
        registry.addInterceptor(new AuthorizationInterceptor())
                //添加路径规则
                .addPathPatterns(pathPatterns)
                //添加排除路径规则
                .excludePathPatterns(excludePathPatterns);
    }
}
